package com.giveu.signature.common.util;

import java.lang.reflect.InvocationTargetException;
import java.util.HashMap;
import java.util.Map;

import org.springframework.beans.BeanUtils;


public class BeanUtil {
	
	public static void copyProperties(Object source, Object target) {
		if(source!=null){
			BeanUtils.copyProperties(source, target);
		}
	}

	public static Map<String, String> describe(Object object) throws IllegalAccessException, InvocationTargetException, NoSuchMethodException {
		Map<String, String> map = org.apache.commons.beanutils.BeanUtils.describe(object);
		Map<String,String> tbMap = new HashMap<>();
		for (Map.Entry<String,String> entity : map.entrySet()) {
			if(entity.getValue()!=null&&!"class".equals(entity.getKey())){
				tbMap.putIfAbsent(entity.getKey(), entity.getValue());
			}
		}
		return tbMap;
	}
}
